package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/edge"
	"entgo.io/ent/schema/field"

	cent "gitee.com/shuokeyun/common/ent"
)

type OrderExt struct {
	ent.Schema
}

func (OrderExt) Mixin() []ent.Mixin {
	return []ent.Mixin{
		cent.OrmMixin{},
	}
}

func (OrderExt) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.Annotation{
			Table: "sk_order_ext",
		},
	}
}

func (OrderExt) Fields() []ent.Field {
	return []ent.Field{
		field.Int64("order_id").Comment("订单id"),
		field.String("remark").Default("").Comment("备注"),
		field.String("department").Default("").Comment("科室"),
		field.String("outpatient_no").Default("").Comment("门诊号/住院号"),
		field.String("bed_no").Default("").Comment("门诊号/床号"),
		field.String("clinical_diagnosis").Default("").Comment("临床诊断"),
	}
}

func (OrderExt) Edges() []ent.Edge {
	return []ent.Edge{
		edge.From("order", Order.Type).Ref("ext").Unique().Required().Field("order_id"),
	}
}
